package com.Test;

import java.util.*;
import java.util.stream.Collectors;

public class Test13 {
    public static void main(String[] args) {

        Map<Integer, String> map = new HashMap<>();

        map.put(1, "Apple");
        map.put(2, "Banana");
        map.put(3, "Orange");

        // 转换为List<String>，使用Stream和Collectors.toList()
        List<String> list4 = map.entrySet().stream()
                .map(entry -> entry.getValue())
                .collect(Collectors.toList());

        System.out.println(list4);


        Map<Integer, List<String>> listMap = new HashMap<>();
        listMap.put(1, Arrays.asList("10", "20"));
        listMap.put(2, Arrays.asList("30", "40"));
        listMap.put(3, Arrays.asList("50", "60"));

        // 转换为List<String>，使用Stream和Collectors.toList()
        List<List<String>> listList = listMap.entrySet().stream()
                .map(entry -> entry.getValue())
                .collect(Collectors.toList());

        ArrayList<String> arrayList = new ArrayList<>();

        if (listList.size() > 0) {
            for (List<String> stringList : listList) {
                arrayList.addAll(stringList);
            }
        }

        if (arrayList.size() > 0) {
            for (String s : arrayList) {
                System.out.println(s);
            }
        }

    }
}
